package io.polly.ldz.config;

import io.polly.ldz.filter.JwtInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @Author ldz112@163.com
 * @Classname WebConfig
 * @Version V1.0
 * @Description TODO
 * @Date 2025/5/27 11:46
 * Copyright (C) 2023 All Rights Reserved
 */
@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private SystemConfig systemConfig;
    @Autowired
    private JwtInterceptor jwtInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        List<String> securityIgnoreUrls = systemConfig.getSecurityIgnoreUrls();
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/v1/**")
                .excludePathPatterns(securityIgnoreUrls);

    }
}
